﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace _430GroupProject
{
    //Group of users that are related through work.  Could be professor and TAs, or other relationships.
    [DataContractAttribute]
    public class WorkGroup : SuperClass
    {
        /// <summary>
        /// The Name of this WorkGroup,  this should be unique among all workgroups.
        /// </summary>
        [DataMember]
        public String Name { get; private set; }

        /// <summary>
        /// The payroll user who is responsible for handling the time sheets for users in this workgroup.
        /// </summary>
        [DataMember]
        public String PayrollID { get; set; } 
        //public User PayrollContact { get; private set; }

        /// <summary>
        /// Users who supervise the Employees in this work group.  Time sheets will be submited to all supervisors, and can be approved by any of these supervisors.
        /// </summary>
        [DataMember]
        public String SupervisorID { get; set; }
        //public List<User> Supervisors { get; set; }

        /// <summary>
        /// The employees for this work group.  The employees will submit timesheets to the supervisors of this work group.
        /// </summary>
        [DataMember]
        public List<User> Employees { get; private set; }

        [DataMember]
        public List<Schedule> Schedules { get; set; }

        public WorkGroup() { }
        /// <summary>
        /// Creates a new WorkGroup with the given Name, payroll contact, and a single superviosr user.
        /// </summary>
        /// <param name="Name">The Name of the workgroup.</param>
        /// <param name="payrollContact">This work groups payroll contact.</param>
        /// <param name="supervisor">A supervisor for this workgroup.</param>
        public WorkGroup(String Name, User payrollContact, User supervisor) {
            this.Name = Name;
            //this.Supervisors = new List<User>();
            //Supervisors.Add(supervisor);
            this.PayrollID = payrollContact.NetID;
            this.SupervisorID = supervisor.NetID;
            supervisor.Manages.Add(this.Name);
            this.Employees = new List<User>();
        }
        
        public void addEmployee(User user) {
            Employees.Add(user);
            user.WorksIn.Add(this.Name);
        }

        public void removeEmployee(User user) {
            Employees.Remove(user);
            user.WorksIn.Remove(this.Name);
        }
    }
}
